package com.cndw.kungfu.model;

import java.io.Serializable;

import com.cndw.kungfu.core.CacheDataBase;
import com.cndw.kungfu.core.CacheDataKey;
import com.cndw.kungfu.model.activity.holiday.KiteData;
import com.cndw.kungfu.model.activity.holiday.LoverDayData;
import com.cndw.kungfu.model.activity.holiday.MMFlowerData;
import com.cndw.kungfu.model.activity.holiday.MidAutumnData;
import com.cndw.kungfu.model.activity.holiday.PoetryData;

public class HolidayCommSerialize extends CacheDataBase implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1570432797016503581L;
	
	/**
	 * 情人节活动
	 */
	private transient LoverDayData loverDayData;

	/**
	 * 中秋活动
	 */
	private transient MidAutumnData midAutumnData;
	/**
	 * 主播活动
	 */
	private transient MMFlowerData mmFlowerData;
	/**
	 * 重阳放风筝活动
	 */
	private transient KiteData kiteData;
	/**
	 * 秦淮诗会
	 */
	private PoetryData poetryData;
	
	
	private static HolidayCommSerialize instance = null;
	
	private HolidayCommSerialize () {
	}
	
	public static HolidayCommSerialize getInstance() {
		if (instance == null) {
			synchronized (HolidayCommSerialize.class) {
				if (instance == null) {
					CacheDataBase cacheData = Context.getSysServer().initCacheData(CacheDataKey.keyHolidayCommSerialize);
					if (cacheData != null && cacheData instanceof HolidayCommSerialize) {
						instance = (HolidayCommSerialize) cacheData;
					}
					if (instance == null) {
						instance = new HolidayCommSerialize();
					}
					if (instance.getSyncDBTime() == 0) {
						instance.commitSync();
					}
				}
			}
		}
		return instance;
	}
	
	public LoverDayData getLoverDayData() {
		if (loverDayData == null) {
			synchronized (HolidayCommSerialize.class) {
				if (loverDayData == null) {
					loverDayData = new LoverDayData();
				}
			}
		}
		return loverDayData;
	}
	
	public MidAutumnData getMidAutumnData() {
		if (midAutumnData == null) {
			synchronized (HolidayCommSerialize.class) {
				if (midAutumnData == null) {
					midAutumnData = new MidAutumnData();
				}
			}
		}
		return midAutumnData;
	}
	
	public MMFlowerData getMMFlowerData() {
		if (mmFlowerData == null) {
			synchronized (HolidayCommSerialize.class) {
				if (mmFlowerData == null) {
					mmFlowerData = new MMFlowerData();
				}
			}
		}
		return mmFlowerData;
	}
	
	public KiteData getKiteData() {
		if (kiteData == null) {
			synchronized (HolidayCommSerialize.class) {
				if (kiteData == null) {
					kiteData = new KiteData();
				}
			}
		}
		return kiteData;
	}
	
	public PoetryData getPoetryData() {
		if (poetryData == null) {
			synchronized (HolidayCommSerialize.class) {
				if (poetryData == null) {
					poetryData = new PoetryData();
					poetryData.init();
				}
			}
		}
		return poetryData;
	}


	@Override
	public String getKey() {
		return CacheDataKey.keyHolidayCommSerialize;
	}


}
